package edu.hawaii.nearestneighbor.tests;

import static org.junit.Assert.*;

import org.junit.Test;

import edu.hawaii.nearestneighbor.util.Gamma;

/**
 * Test cases for the Gamma class.
 * @author Robert Puckett
 *
 */
public class TestGamma {

  /**
   * Tests the gamma function against various known values.
   */
  @Test
  public void testGamma() {
    double g1 = Gamma.gamma(4);
    double g2 = Gamma.gamma(-3.0 / 2.0);
    double g3 = Gamma.gamma(7.0 / 2.0);
    double g4 = Gamma.gamma(4.0 / 5.0);
    double t = 0.001;
    
    assertTrue("Gamma test 1", (Math.abs(g1 - 6.0) < t));
    assertTrue("Gamma test 2", (Math.abs(g2 - 2.363) < t));
    assertTrue("Gamma test 3", (Math.abs(g3 - 3.323) < t));
    assertTrue("Gamma test 4", (Math.abs(g4 - 1.1642) < t));

  }

}
